<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1">
<input type="button" value="添加帅哥" onclick="f(1)">
<input type="button" value="添加美女" onclick="f(2)">

<script>
    let i1 = document.querySelector("#i1");
  function f(x) {
    let imgName = x==1?"a.jpg":"b.jpg";
    for (i=0;i<parseInt(i1.value);i++){
      let m = document.createElement("img");
      m.src = imgName;
      document.body.append(m);
    }
  }
</script>
</body>
</html>